﻿/*
This file is under Microsoft Public License (MS-PL)
Copyright Yohann MARTEL.  All rights reserved.
Codeplex: http://amf.codeplex.com
AMF Website: http://www.ymartel.com/aspnet-mobile-framework/
*/
using System;
using System.ComponentModel;
using System.Web.UI;

namespace Mobile.WebControls
{
    [ToolboxData("<{0}:LinkButton runat=server></{0}:LinkButton>")]
    public class LinkButton : Link
    {
        #region Properties
        [Category("Appearance")]
        public bool IsInLine { get; set; }

        [Category("Appearance")]
        public ButtonPosition HeaderButtonPosition { get; set; }
        #endregion

        #region Render Methods
        protected override void Render(HtmlTextWriter writer)
        {
            if (Visible)
                base.Render(writer);
        }

        protected override void AddAttributesToRender(HtmlTextWriter writer)
        {
            base.AddAttributesToRender(writer);
            writer.AddAttribute(MetadataAttribute.DataRole, DataRole.Button);
            if (IsInLine)
            {
                writer.AddAttribute(MetadataAttribute.DataInline, Boolean.TrueString.ToLower());
            }
            if (HeaderButtonPosition != ButtonPosition.None)
            {
                switch(HeaderButtonPosition)
                {
                    case ButtonPosition.Left:
                        writer.AddAttribute(HtmlTextWriterAttribute.Class, JqueryCssClass.BottonPositionLeft);
                        break;
                    case ButtonPosition.Right:
                        writer.AddAttribute(HtmlTextWriterAttribute.Class, JqueryCssClass.ButtonPositionRight);
                        break;
                }
            }
        }
        #endregion
    }

}
